package cat.tom.controller;

import cat.tom.mapper.TypeMapper;
import cat.tom.pojo.Type;
import cat.tom.pojo.vo.PortalVo;
import cat.tom.service.HeadlineService;
import cat.tom.service.TypeService;
import cat.tom.utils.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author shkstart
 * @create 2024-03-10 0:28
 */
@RestController
@RequestMapping("portal")
@CrossOrigin
public class PortalController {

    @Autowired
    private TypeService typeService;

    @Autowired
    private HeadlineService headlineService;

    @GetMapping("findAllTypes")
    public Result findAllTypes(){
        List<Type> list = typeService.list();
        return Result.ok(list);
    }

    @PostMapping("findNewsPage")
    public Result findNewsPage(@RequestBody PortalVo portalVo){
        Result result = headlineService.findNewPage(portalVo);
        return result;

    }

    @PostMapping("showHeadlineDetail")
    public Result showHeadlineDetail(@Param("hid") Integer hid){
        Result result = headlineService.showHeadlineDetail(hid);
        return result;

    }
}
